package jwt

import (
	"time"

	"github.com/dgrijalva/jwt-go/v4"
)

func SignJwt(username string, level string, uid string) (string, error) {
	token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
		"username": username,
		"level":    level,
		"uid":      uid,
		"iat":      time.Now().Unix(),
		"exp":      time.Now().Add(time.Hour * 1).Unix(),
	})

	// Sign and get the complete encoded token as a string using the secret
	tokenString, err := token.SignedString([]byte("2toZTm48Uouef6rQrHVhnVn4X"))

	// fmt.Println(tokenString, err)
	return tokenString, err
}
